﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Singleton
{
    public class Singleton
    {

        /// <summary>
        /// Protected constructor
        /// </summary>
        private Singleton()
        {}

        /// <summary>
        /// Additional property
        /// </summary>
        public int Value { get; set; }

        private static readonly object key = new object();

        /// <summary>
        /// this class object
        /// </summary>
        private static Singleton instance;

        /// <summary>
        /// Return this class object or create new if it doesn't not exist
        /// </summary>
        public static Singleton Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (key)
                    {
                        instance = new Singleton();
                    }
                }
                return instance;
            }
        }
    }
}
